#include<bits/stdc++.h>
using namespace std;
int a[1000010];
int b[1000010];
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t,maxn=0,ans=0;
    cin>>t;
    while(t--)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        ans=0;
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            b[a[i]]++;
            maxn=max(maxn,a[i]);
        }
        for(int i=1;i<=maxn;i++)
        {
            ans+=(int(b[i]/2)*i);
            //cout<<b[i]<<' ';
        }
        cout<<ans<<"\n";
    }
    return 0;
}
